package com.ewzj.bigdata.mvp.ui.adapter

import android.view.View
import android.widget.ImageView

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.ewzj.bigdata.R
import com.ewzj.bigdata.app.config.AppKey
import com.ewzj.bigdata.app.extensions.loadImgwithloading
import com.ewzj.bigdata.mvp.model.rspbean.VideoBean
import com.ewzj.bigdata.mvp.ui.activity.VideoWebActivity
import com.ewzj.bigdata.mvp.ui.activity.WebViewActivity
import com.jakewharton.rxbinding2.view.RxView


/**
 * author:zhangjing
 * 作用:
 * return:
 */

class VideoAdapter(data: List<VideoBean>) : BaseQuickAdapter<VideoBean, BaseViewHolder>(R.layout.item_video, data) {

    override fun convert(baseViewHolder: BaseViewHolder, videoBean: VideoBean) {
        baseViewHolder.getView<ImageView>(R.id.iv_pic).loadImgwithloading(videoBean.getThumb())
        baseViewHolder.setText(R.id.tv_tltle, videoBean.getTitle())
        //        baseViewHolder.setText(R.id.tv_time,videoBean.get());
        baseViewHolder.setText(R.id.tv_des, "#" + videoBean.getType() + "/" + videoBean.getDuration())
        baseViewHolder.setText(R.id.tv_video, videoBean.getDuration())
        baseViewHolder.setText(R.id.tv_source, videoBean.sources)
        baseViewHolder.setText(R.id.tv_time, videoBean.create_time)
        RxView.clicks(baseViewHolder.convertView).subscribe({
            AppKey.mchaneObject=videoBean
            if (videoBean.is_self==-1){
                WebViewActivity.startWebView(mContext,videoBean.title,videoBean.three_url)
            }else{
                VideoWebActivity.startVideoWebView(mContext,videoBean)
            }
        })
    }
}
